import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AdvertisingVO, AdvertisingForm, AdvertisingQuery } from './types';

/**
 * 查询广告列表
 * @param query
 * @returns {*}
 */

export const listAdvertising = (query?: AdvertisingQuery): AxiosPromise<AdvertisingVO[]> => {
  return request({
    url: '/system/advertising/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询广告详细
 * @param advertisingId
 */
export const getAdvertising = (advertisingId: string | number): AxiosPromise<AdvertisingVO> => {
  return request({
    url: '/system/advertising/' + advertisingId,
    method: 'get'
  });
};

/**
 * 新增广告
 * @param data
 */
export const addAdvertising = (data: AdvertisingForm) => {
  return request({
    url: '/system/advertising',
    method: 'post',
    data: data
  });
};

/**
 * 修改广告
 * @param data
 */
export const updateAdvertising = (data: AdvertisingForm) => {
  return request({
    url: '/system/advertising',
    method: 'put',
    data: data
  });
};
/**
 * 审核广告
 * @param data
 */
export const examineAdvertisingApi = (data: AdvertisingForm) => {
  return request({
    url: '/system/advertising/examineAdvertising',
    method: 'put',
    data: data
  });
};

/**
 * 删除广告
 * @param advertisingId
 */
export const delAdvertising = (advertisingId: string | number | Array<string | number>) => {
  return request({
    url: '/system/advertising/' + advertisingId,
    method: 'delete'
  });
};
